<?php
/**
 * 售后
 * User: tengyu
 * Date: 2017/10/30
 * Time: 13:12
 */?>
@extends('common.common')
@section('title','在租-售后')
@section('css')
    <link rel="stylesheet" href="{{asset('/css/applyService_shou.css')}}">
    <link rel="stylesheet" href="{{asset('/fileinput/fileinput.min.css')}}">
@endsection
@section('js')
    <script type="text/javascript" src="{{asset('/js/applyService_shou.js')}}"></script>
    <script type="text/javascript" src="{{asset('/fileinput/fileinput.min.js')}}"></script>
    <script type="text/javascript" src="{{asset('/fileinput/zh.js')}}"></script>
    <script>
        /**
         * 维修数量减操作-
         */
        function decreback()
        {
            var num = $("#rentrepair_num").text();
            //var rentrepair_num = $("input[name='rentrepair_num']").val();
            if(num-1<1){
                alert('售后数量已达下限');
            }else{
                num = num-1;
                $("#rentrepair_num").text(num);
            }
        }
        /**
         * 维修数量加操作 +
         * @cartid当前在租订单详情id
         */
        function increback()
        {
            var rentback_num = parseInt($("input[name='rentrepair_num']").val());
            var num = parseInt($("#rentrepair_num").text());
            num = num+1;
            if(num>rentback_num){
                alert('售后数量超出当前在租数量!');
                return false;
            }else{
                $("#rentrepair_num").text(num);
            }
        }
        /**报修图片上传*/
      $("#repair_file").fileinput({
            language: 'zh', //设置语言
            uploadUrl: false,
            enctype: 'multipart/form-data',
            allowedFileExtensions: ['jpg', 'png', 'gif','jpeg'],  //接受文件的后缀
            showUpload: false,                                       //是否显示上传按钮
            showPreview:true,                                        //展前预览
            showCaption: false,                                      //是否显示标题
            dropZoneEnabled: false,                                  //是否显示拖拽区域
            maxFileSize: 4000,                                        //上传文件最大的尺寸
            minFileCount:0,
            maxFileCount:5,                                           //限制文件最大上传书
            uploadAsync: false,                                       //是否异步上传
            allowedFileTypes:['image'],                              //文件类型审核
            validateInitialCount:true,
            previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
            msgFilesTooMany: "选择上传的文件数量({n}) 超过允许的最大数值{m}！",
            layoutTemplates:{
                //actionDelete:'',//去除上传预览的缩略图中的删除图标
                //actionZoom:'', //去除上传预览缩略图中的查看详情图标
                actionUpload:''//去除上传舆论缩略 图中的上传图片
            },
            slugCallback: function (filename) { //预览图片设置
                return filename.replace('(', '_').replace(']', '_');
            }
        });

        //上传售后资料
        function repair_post()
        {
            //return true;
            var obj = document.getElementById("repair_file");
            console.log(obj.files.length);
            var input = document.getElementById('repair_file');
            var li = '';
            for (var x = 0; x < input.files.length; x++) {;
                li = li + input.files[x].name;
            }
            alert('后台逻辑修改中,敬请期待!');
            return false;
        }
    </script>
@endsection
@section('content')
    <div id="content">
        @include('common.centernav')
        <h3>个人中心</h3>
        <div class="container">
            <div class="row">
                @include('usercenter.usersidebar')
                <!--2、右侧主体-->
                <div class="col-xs-9">
                    <!--右侧面版-->
                    <div id="panel" class="panel panel-default rightPanel">
                        <div class="panel-heading">
                            <h4 class="myorder">申请售后</h4>
                        </div>
                        @if(is_object($param['rentrepair_dt']))
                        <form class="panel-body" action="{{asset('/user/rentrepair_post')}}" method="post" enctype="multipart/form-data" onsubmit="return repair_post()">
                            {!! csrf_field() !!}
                            <p class="productDate">
                                <span>下单日期:</span>
                                <span>{{substr($param['rentrepair_dt']->created_at,0,10)}}</span>&nbsp;&nbsp;
                                <span>订单号:</span>
                                <span>{{substr($param['rentrepair_dt']->details_orderNo,0,10)}}</span>&nbsp;&nbsp;
                                <span>订单金额:</span>
                                @if($param['rentrepair_dt']->details_rent_type==1)
                                <span class="red">{{$param['rentrepair_dt']->details_nimbleprice*$param['rentrepair_dt']->details_fitment_number*2+$param['rentrepair_dt']->details_bond*$param['rentrepair_dt']->details_fitment_number}}</span>
                                @else
                                <span class="red">{{$param['rentrepair_dt']->details_fixprice*$param['rentrepair_dt']->details_fitment_number+$param['rentrepair_dt']->details_bond*$param['rentrepair_dt']->details_fitment_number}}</span>
                                @endif
                                <span class="red">元</span>
                                <a class="rt" href="{{url('/user/orderdt/'.$param['rentrepair_dt']->id)}}">订单详情</a>
                            </p>
                            <!--列表组-->
                            <ul class="orders list-inline">
                                <li class="imgInfo">
                                    <img class="img-responsive" src="{{asset(env('STATIC_FILE_ERP_PATH').$param['rentrepair_dt']->fitment_details_imgMaster)}}" style="width: 151px;height: 92px;">
                                </li>
                                <li>
                                    月租金:<span>@if($param['rentrepair_dt']->details_rent_type==1){{$param['rentrepair_dt']->details_nimbleprice}}@else{{$param['rentrepair_dt']->details_fixprice}}@endif</span>元
                                    @if(1>2)<br>单套押金:<span>23123</span>元@endif
                                </li>
                                <li>
                                    @if($param['rentrepair_dt']->details_rent_type==1)
                                    支付押金:<span>{{$param['rentrepair_dt']->details_nimbleprice*$param['rentrepair_dt']->details_fitment_number*2}}</span>元
                                        @else
                                    支付押金:<span>0</span>
                                    @endif
                                    <br>
                                    <span>@if($param['rentrepair_dt']->details_rent_type==1){{'随租支付两个月押金'}}@else{{'租满即送无押金'}}@endif</span>
                                </li>
                                <li>
                                订单数量:<span>{{$param['rentrepair_dt']->details_fitment_number}}</span>
                                <br>
                                    @if($param['rentrepair_dt']->details_rent_type==1)
                                    账单金额:<span>{{$param['rentrepair_dt']->details_nimbleprice*$param['rentrepair_dt']->details_fitment_number}}</span>元
                                        @else
                                    账单金额:<span>{{$param['rentrepair_dt']->details_fixprice*$param['rentrepair_dt']->details_fitment_number}}</span>元
                                    @endif
                                </li>
                                <li>起租日期:<span>{{substr($param['rentrepair_dt']->details_fitment_start,0,10)}}</span>
                                    <br>租期:<span>@if($param['rentrepair_dt']->details_rent_type==1){{'12'}}@else{{'18'}}@endif</span>个月
                                </li>
                            </ul>
                            <input type="hidden" name="rentrepair_num" value="{{$param['rentrepair_dt']->details_fitment_number}}">
                            <div class="mediaInformation">
                                <span>{{$param['rentrepair_dt']->details_name}}*</span>
                                <span>{{$param['rentrepair_dt']->details_fitment_number}}</span>
                                <img src="/img/color.jpg">
                                <span class="red margin">¥</span>
                                <span class="red">@if($param['rentrepair_dt']->details_rent_type==1){{$param['rentrepair_dt']->details_nimbleprice}}@else{{$param['rentrepair_dt']->details_fixprice}}@endif</span>
                                <span class="red">/月</span>
                                <span class="bigMargin">维修数量:</span>
                                <b class="glyphicon glyphicon-minus-sign" onclick="decreback()"></b>
                                <span class="number" id="rentrepair_num">{{$param['rentrepair_dt']->details_fitment_number}}</span>
                                <b class="glyphicon glyphicon-plus-sign" onclick="increback()"></b>
                            </div>
                            <div class="container-fluid">
                                <div class="row">
                                    <div class="col-xs-2">收货地址:</div>
                                    <div class="col-xs-10">
                                        <span>{{$param['rentrepair_dt']->addr_rename}}:</span>
                                        <span>{{$param['rentrepair_dt']->addr_rephone}}</span>
                                        <span>（{{$param['rentrepair_dt']->addr_area.$param['rentrepair_dt']->addr_town.$param['rentrepair_dt']->addr_detail}}）</span>
                                    </div>
                                </div>
                                {{--<div class="row">--}}
                                <div class="form-group">
                                    <div class="file-loading">
                                        <input type="file" id="repair_file" name="repair_file[]" multiple class=“file-loading” data-overwrite-initial="false" data-min-file-count="0" data-show-caption="true">
                                    </div>
                                </div>
                                {{--    <div class="col-xs-2">
                                        故障图片:
                                    </div>
                                    <div class="col-xs-10 problem">
                                        <div class="problemPic"></div>
                                        <span>为了方便售后技术人员判断故障、帮助您快速解决问题，建议您上传故障图片！请上传格式jpg、png、gif、的图片，图片请小于4M。</span>
                                    </div>
                                    <input type="file" name="rentrepair_img" id="up_img">--}}
                                {{--</div>--}}
                                <div class="row specialMargin">
                                    <div class="col-xs-2">
                                        维修原因:
                                    </div>
                                    <div class="col-xs-10">
                                        <textarea name="reason" id="repair_reason" maxlength="200" placeholder="请填写维修原因，长度在200字以内。"></textarea>
                                    </div>
                                </div>
                                <div class="row special">
                                    <!--此div误删，占位用-->
                                    <div class="col-xs-2"></div>
                                    <div class="col-xs-10">
                                        <span>备注：人为损坏需要支付维修费用</span>
                                    </div>
                                </div>
                                <div class="row">
                                    <!--此div误删，占位用-->
                                    <div class="col-xs-2"></div>
                                    <div class="col-xs-10">
                                        <button class="btn btn-warning" type="submit">立即申请</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                        @endif
                    </div>
                </div>
            </div>
        </div>
    </div>
    </div>
@endsection